﻿<UserControl x:Class="Peter.Sdw.View.BookView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:logic="clr-namespace:Peter.Sdw.Logic"
             xmlns:icons="clr-namespace:Peter.Common.Icons;assembly=Peter.Common"
             xmlns:view="clr-namespace:Peter.Sdw.View"
             mc:Ignorable="d"
             d:DesignHeight="500"
             d:DesignWidth="600"
             d:DataContext="{d:DesignInstance logic:BookModel}">
   <UserControl.Resources>
      <BooleanToVisibilityConverter x:Key="_BoolToVisi" />
   </UserControl.Resources>
   <Grid>
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto" />
         <RowDefinition Height="*" />
      </Grid.RowDefinitions>

      <Expander Header="Book Details"
                IsExpanded="True"
                Grid.Row="0">
         <Grid>
            <Grid.RowDefinitions>
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
               <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
               <ColumnDefinition Width="*" />
               <ColumnDefinition Width="*" />
               <ColumnDefinition Width="*" />
               <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <TextBlock Text="Title"
                       VerticalAlignment="Center"
                       Grid.Row="0"
                       Grid.ColumnSpan="2"
                       Grid.Column="0"/>
            <TextBox Text="{Binding Path=Title}"
                     Grid.Column="0"
                     Grid.ColumnSpan="2"
                     Grid.Row="1" />
            <TextBlock Text="Subtitle"
                       VerticalAlignment="Center"
                       Grid.Column="0"
                       Grid.Row="2" />
            <TextBox Text="{Binding Path=SubTitle}"
                     Grid.Column="0"
                     Grid.Row="3" />
            <TextBlock Text="Term"
                       Margin="5,0"
                       VerticalAlignment="Center"
                       Grid.Column="1"
                       Grid.Row="2" />
            <Grid Grid.Column="1"
                  Grid.Row="3">
               <Grid.ColumnDefinitions>
                  <ColumnDefinition Width="*" />
                  <ColumnDefinition Width="Auto" />
               </Grid.ColumnDefinitions>
               <TextBox Text="{Binding Path=TermName}"
                        Grid.Column="0"
                        IsReadOnly="True"
                        Margin="5,0" />
               <Button Grid.Column="1"
                       ToolTip="Select a Term"
                       Command="{Binding Path=SelectTermCommand}">
                  <icons:IconDisplay Icon="Browser"
                                     Margin="5,0"/>
               </Button>
            </Grid>
            <TextBlock Text="Summary"
                       Margin="5,0"
                       VerticalAlignment="Top"
                       Grid.Column="2"
                       Grid.ColumnSpan="2"
                       Grid.Row="0" />
            <TextBox Text="{Binding Path=Summary}"
                     VerticalScrollBarVisibility="Auto"
                     TextWrapping="WrapWithOverflow"
                     VerticalAlignment="Stretch"
                     AcceptsReturn="True"
                     Grid.Column="2"
                     Grid.ColumnSpan="2"
                     Margin="5,0"
                     Grid.Row="1"
                     Grid.RowSpan="3"/>
         </Grid>
      </Expander>
      
      <GroupBox Grid.Row="1">
         <GroupBox.Header>
            <StackPanel Orientation="Horizontal"
                        Margin="0,5">
               <TextBlock Text="Versions"
                          VerticalAlignment="Center"/>
               <Button Margin="5,0"
                       ToolTip="Add a new version for this book"
                       Command="{Binding Path=AddVersionCommand}">
                  <icons:IconDisplay Icon="PlusSign"
                                     IconSize="Small"
                                     Margin="5,0"/>
               </Button>
            </StackPanel>
         </GroupBox.Header>
         <Grid>
            <TabControl ItemsSource="{Binding Path=Versions}"
                        SelectedValue="{Binding Path=SelectedVersion}">
               <TabControl.ItemTemplate>
                  <DataTemplate>
                     <TextBlock Text="{Binding Path=Title}" />
                  </DataTemplate>
               </TabControl.ItemTemplate>
               <TabControl.ContentTemplate>
                  <DataTemplate DataType="{x:Type logic:VersionModel}">
                     <view:VersionView />
                  </DataTemplate>
               </TabControl.ContentTemplate>
            </TabControl>

            <Border Grid.Row="0"
                    Height="75"
                    Width="150"
                    CornerRadius="5"
                    Background="SteelBlue"
                    Visibility="{Binding Path=IsLoading, Converter={StaticResource _BoolToVisi}}">
               <TextBlock Text="Loading..."
                          FontSize="16"
                          Foreground="White"
                          FontStyle="Italic"
                          HorizontalAlignment="Center"
                          VerticalAlignment="Center" />
            </Border>
         </Grid>
      </GroupBox>
   </Grid>
</UserControl>
